package com.chaoyi.controller.Video;

import com.chaoyi.model.ChannelSwitch;
import com.chaoyi.model.Classification;
import com.chaoyi.model.VideoCollection;
import com.chaoyi.service.ChannelSwitchService;
import com.chaoyi.service.ClassificationService;
import com.chaoyi.service.VideoCollectionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: 卜加超
 * @Date: 2019/1/3 11:35
 * @Description:
 */
@Controller
@RequestMapping("/videoCollectionOut")
public class VideoCollectionOutController {
    private Logger logger = LoggerFactory.getLogger(VideoCollectionOutController.class);
    @Resource
    private VideoCollectionService videoCollectionService;
    @Resource
    private ChannelSwitchService channelSwitchService;
    @Resource
    private ClassificationService classificationService;
    /**
     * 根据videotype ，appType 查询视频列表
     * @param videoType 视频类型
     * @param channelId
     * @return
     */
    @RequestMapping("/list/{videoType}/{channelId}/{page}-{pageSize}")
    @ResponseBody
    public List<VideoCollection> getVideoCollectionList(@PathVariable("videoType")int videoType,
                                                        @PathVariable("channelId") String channelId,
                                                        @PathVariable("page")int page, @PathVariable("pageSize")int pageSize){
        //todo  根据 channelId 查询type类型 默认type为白包
        ChannelSwitch channelSwitch =  channelSwitchService.selectChannelSwitchByChannel(channelId);
        logger.info("渠道开关+"+channelSwitch.getChannelType());
        List<VideoCollection> list = new ArrayList<>();
        if(channelSwitch.getChannelType()==1){
            list = videoCollectionService.getVideoCollectionList(videoType,page,pageSize);
        }
        return list;
    }
    @RequestMapping("/list")
    @ResponseBody
    public List<Classification> getClassficationList(){
        return classificationService.selectClassficationList();
    }

}
